import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from "@angular/router";
import { StockTopBarService, TOP_BAR_TYPE_CHART, ACTION_SET_BAR_TYPE } from "stock";

@Component({
  // moduleId: module.id,
  selector: 'stock-tick',
  templateUrl: 'stock-tick.component.html',
})
export class StockTickComponent implements OnInit {
  stockSource;

  constructor(private router: ActivatedRoute, private topbar: StockTopBarService) { }

  ngOnInit() {

    this.stockSource =
      this.router.parent.params.map(params => params["id"]).filter(id => !!id).map(id => {
        return {
          symbol: (<string>id).replace("_", ".")
        }
      })

    this.topbar.source.next({
      type: ACTION_SET_BAR_TYPE,
      tabType: TOP_BAR_TYPE_CHART,
      payload: []
    });
  }
}